package logic

import (
	"context"
	"rpc/turn"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUpdateStatusLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUpdateStatusLogic {
	return &UserUpdateStatusLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserUpdateStatusLogic) UserUpdateStatus(req *types.UserUpdateStatusRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	status, err := l.svcCtx.TurnSrv.UserUpdateStatus(l.ctx, &turn.UserUpdateStatusRequest{
		Userid: req.UserId,
		Status: int64(req.Status),
	})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}

	return &types.Response{
		Code: 200,
		Msg:  "用户状态修改成功",
		Data: map[string]interface{}{"status": status},
	}, nil
}
